﻿<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">

	<description>
		This Macro demonstrates how a Powershell Scripts and STSADM Scripts can be run from one Macro.
	</description>

	<object id="MacroToProcess" type="Macro" >
		<constructor-arg name="templateId" value="{4C0CAF35-C2A1-4811-1111-EA421B301B7F}" />
		<constructor-arg name="actions">
			<list element-type="IAction">				
				<!-- ============================ -->
				<!-- POWERSHELL COMMANDS          -->
				<!-- ============================ -->
				<object name="Powershell1" id="Powershell1" type="Action.Powershell">
					<property name="EntityList">
						<object type="Entity.PowershellScriptInfo">
							<!-- This Script will be run during the "Do" -->
							<property name="DoScript">
								<object type="Entity.PowershellScript">
									<property name="ScriptFile" value="${CurrentDirectory}\..\..\_PSScripts\Export-SharePoint-List.ps1" />
									<property name="VerbosePreference" value="continue" />
									<property name="DebugPreference" value="continue" />
									<property name="ErrorActionPreference" value="continue" />
									<property name="ShouldProcessPreference" value="continue" />
									<property name="ProcessReturnPreference" value="continue" />
									<property name="Commands">
										<list element-type="string">
											<value>Export-List ${CurrentWeb.Url}/Lists/Tasks</value>
											<value>dir >${CurrentDirectory}\DirectoryListing.txt</value>
											<value>copy ${CurrentDirectory}\DirectoryListing.txt c:\temp</value>
										</list>
									</property>
								</object>
							</property>
							<!-- This Script will be run during the "Undo" -->
							<property name="UndoScript">
								<!-- Do Nothing -->
							</property>
						</object>
					</property>
					<property name="StopOnDoException" value="${StopOnDoException}"/>
					<property name="StopOnUndoException" value="${StopOnUndoException}"/>
					<property name="AutoUndo" value="${AutoUndo}"/>
					<property name="DisableDo" value="${DisableDo}"/>
					<property name="DisableUndo" value="${DisableUndo}"/>
				</object>
				
				<!-- ==================== -->
				<!-- STSADM COMMANDS      -->
				<!-- ==================== -->
				<object name="RunStsAdminCommands" type="Action.StsAdmin">
					<property name="EntityList">
						<object id="StsAdminCommandList" type="Entities">
							<constructor-arg>
								<list>
									<!-- =========================== -->
									<!-- Delete a Group using STSADM -->
									<!-- =========================== -->
									<object type="Entity.StsAdminCommand">
										<property name="Operation" value="deletegroup" />
										<property name="Arguments">
											<object type="SafDictionary">
												<constructor-arg name="dictionary">
													<dictionary>
														<entry key="url" value="${CurrentWeb.Url}"/>
														<entry key="name" value="SAF Demo Group"/>
													</dictionary>
												</constructor-arg>
											</object>
										</property>
									</object>
									<!-- ============================= -->
									<!-- Create the Group using STSADM -->
									<!-- ============================= -->
									<object type="Entity.StsAdminCommand">
										<property name="Operation" value="creategroup" />
										<property name="Arguments">
											<object type="SafDictionary">
												<constructor-arg name="dictionary">
													<dictionary>
														<entry key="url" value="${CurrentWeb.Url}"/>
														<entry key="name" value="SAF Demo Group"/>
														<entry key="description" value="This is a group create by SAF"/>
														<entry key="ownerlogin" value="${CurrentUser}"/>
														<entry key="type" value="owner"/>
													</dictionary>
												</constructor-arg>
											</object>
										</property>
									</object>
								</list>
							</constructor-arg>
						</object>
					</property>
					<property name="StopOnDoException" value="false"/>
				</object>
				<!-- ==================== -->
				<!-- SAF ACTIONS          -->
				<!-- ==================== -->
				<object name="AddContentType1" type="Action.AddContentTypeToList">
					<property name="EntityList">
						<object id="ListOfCtypes" type="Entities">
							<constructor-arg>
								<list>
									<!-- =============================================== -->
									<!-- Adds a Content Type to a List called "TestList" -->
									<!-- =============================================== -->
									<object type="Entity.ContentTypeToListMapping">
										<property name="SiteUrl" value="${CurrentWeb.Url}" />
										<property name="ContentTypeName" value="TestCtype"/>
										<property name="ListName" value="TestList" />
										<property name="AddIfUnavailable" value="True"/>
										<property name="EnableContentTypesOnList" value="True" />
									</object>
								</list>
							</constructor-arg>
						</object>
					</property>
					<property name="StopOnDoException" value="false"/>
				</object>
			</list>
		</constructor-arg>
	</object>
</objects>

